package org.mch.func.encode;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.TitledBorder;

import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.mch.biz.ui.BizEvent;
import org.mch.biz.ui.BizPanel;

public class EncodePanel extends BizPanel {
	private static final long serialVersionUID = 1L;
	private JSplitPane splitPane;
	private JPanel panel;
	private JPanel panel_1;
	private JButton button_lower;
	private JButton button_upper;
	private JSplitPane splitPane_1;
	private JPanel panel_2;
	private JPanel panel_3;
	private JScrollPane scrollPane;
	private JScrollPane scrollPane_1;
	private RSyntaxTextArea textArea_down;
	private RSyntaxTextArea textArea_up;
	private JButton btn_rep;
	private JButton btn_sqlin;
	private JTextField text_infield;
	private JButton btn_native2ascii;
	private JButton btn_ascii2native;
	private JButton btn_repfile;

	public EncodePanel() {
		initComponents();
	}

	private void initComponents() {
		setLayout(new BorderLayout(0, 0));
		add(getSplitPane(), "Center");
	}

	public JSplitPane getSplitPane() {
		if (this.splitPane == null) {
			this.splitPane = new JSplitPane();
			this.splitPane.setLeftComponent(getPanel());
			this.splitPane.setRightComponent(getPanel_1());
			this.splitPane.setDividerLocation(300);
		}
		return this.splitPane;
	}

	public JPanel getPanel() {
		if (this.panel == null) {
			this.panel = new JPanel();
			this.panel.setLayout(null);
			this.panel.add(getButton_lower());
			this.panel.add(getButton_upper());
			panel.add(getBtn_rep());
			panel.add(getBtn_sqlin());
			panel.add(getText_infield());
			panel.add(getBtn_native2ascii());
			panel.add(getBtn_ascii2native());
			panel.add(getBtn_repfile());
		}
		return this.panel;
	}

	public JPanel getPanel_1() {
		if (this.panel_1 == null) {
			this.panel_1 = new JPanel();
			this.panel_1.setLayout(new BorderLayout(0, 0));
			this.panel_1.add(getSplitPane_1(), "Center");
		}
		return this.panel_1;
	}

	public JButton getButton_lower() {
		if (this.button_lower == null) {
			this.button_lower = new JButton("小写");
			button_lower.setMargin(new Insets(0, 0, 0, 0));
			button_lower.setFont(new Font("宋体", Font.PLAIN, 13));
			this.button_lower.setToolTipText("转换为小写");
			this.button_lower.setBounds(139, 10, 117, 26);
			this.button_lower.addMouseListener(getEvent());
		}
		return this.button_lower;
	}

	public JButton getButton_upper() {
		if (this.button_upper == null) {
			this.button_upper = new JButton("大写");
			button_upper.setMargin(new Insets(0, 0, 0, 0));
			button_upper.setFont(new Font("宋体", Font.PLAIN, 13));
			this.button_upper.setToolTipText("转换为大写");
			this.button_upper.setBounds(10, 10, 117, 26);
			this.button_upper.addMouseListener(getEvent());
		}
		return this.button_upper;
	}

	public JSplitPane getSplitPane_1() {
		if (this.splitPane_1 == null) {
			this.splitPane_1 = new JSplitPane();
			this.splitPane_1.setResizeWeight(0.5D);
			this.splitPane_1.setOrientation(0);
			this.splitPane_1.setLeftComponent(getPanel_2());
			this.splitPane_1.setRightComponent(getPanel_3());
		}
		return this.splitPane_1;
	}

	public JPanel getPanel_2() {
		if (this.panel_2 == null) {
			this.panel_2 = new JPanel();
			panel_2.setBorder(new TitledBorder(null, "\u4E0A\u65B9\u6587\u672C\uFF1A", TitledBorder.LEADING, TitledBorder.TOP, null,
					null));
			this.panel_2.setLayout(new BorderLayout(0, 0));
			this.panel_2.add(getScrollPane(), "Center");
		}
		return this.panel_2;
	}

	public JPanel getPanel_3() {
		if (this.panel_3 == null) {
			this.panel_3 = new JPanel();
			panel_3.setBorder(new TitledBorder(null, "\u4E0B\u65B9\u6587\u672C\uFF1A", TitledBorder.LEADING, TitledBorder.TOP, null,
					null));
			this.panel_3.setLayout(new BorderLayout(0, 0));
			this.panel_3.add(getScrollPane_1(), "Center");
		}
		return this.panel_3;
	}

	public JScrollPane getScrollPane() {
		if (this.scrollPane == null) {
			this.scrollPane = new JScrollPane();
			this.scrollPane.setViewportView(getTextArea_up());
		}
		return this.scrollPane;
	}

	public JScrollPane getScrollPane_1() {
		if (this.scrollPane_1 == null) {
			this.scrollPane_1 = new JScrollPane();
			this.scrollPane_1.setViewportView(getTextArea_down());
		}
		return this.scrollPane_1;
	}

	public RSyntaxTextArea getTextArea_down() {
		if (this.textArea_down == null) {
			this.textArea_down = new RSyntaxTextArea();
			textArea_down.setFont(new Font("宋体", Font.PLAIN, 13));
			this.textArea_down.setBorder(new LineBorder(new Color(0, 0, 0)));
		}
		return this.textArea_down;
	}

	public RSyntaxTextArea getTextArea_up() {
		if (this.textArea_up == null) {
			this.textArea_up = new RSyntaxTextArea();
			textArea_up.setFont(new Font("宋体", Font.PLAIN, 13));
			this.textArea_up.setBorder(new SoftBevelBorder(1, null, null, null, null));
		}
		return this.textArea_up;
	}

	protected BizEvent createEvent() {
		return new ClientEvent(this);
	}

	public JButton getBtn_rep() {
		if (btn_rep == null) {
			btn_rep = new JButton("\u66ff\u6362");
			btn_rep.setMargin(new Insets(0, 0, 0, 0));
			btn_rep.setFont(new Font("宋体", Font.PLAIN, 13));
			btn_rep.setToolTipText("\u5C06\u4E0B\u65B9\u6587\u672C\u6309\u4E0A\u65B9\u66FF\u6362\u89C4\u5219\u66FF\u6362\u540E\uFF0C\u8F93\u51FA\u81F3\u4E0B\u65B9\uFF01\r\n\u4E0A\u65B9\u89C4\u5219\uFF1A\r\naaaa=34567\r\n1234=789\r\n\u6CE8\u610F\uFF1A\u8981\u56DE\u8F66\uFF1B\r\n\u8868\u793A\u5C06\"aaaa\"\u66FF\u6362\u6210\"34567\"\u3001\"1234\"\u66FF\u6362\u6210\"789\"");
			btn_rep.setBounds(10, 48, 117, 26);
			btn_rep.addMouseListener(getEvent());
		}
		return btn_rep;
	}

	public JButton getBtn_sqlin() {
		if (btn_sqlin == null) {
			btn_sqlin = new JButton("SQL_IN");
			btn_sqlin.setMargin(new Insets(0, 0, 0, 0));
			btn_sqlin.setFont(new Font("宋体", Font.PLAIN, 13));
			btn_sqlin.setToolTipText("\u5C06\u4E0A\u65B9\u6587\u672C\uFF0C\u8F6C\u6362\u6210SQLIN");
			btn_sqlin.setBounds(10, 124, 117, 26);
			btn_sqlin.addMouseListener(getEvent());
		}
		return btn_sqlin;
	}

	public JTextField getText_infield() {
		if (text_infield == null) {
			text_infield = new JTextField();
			text_infield.setToolTipText("SQL IN \u5B57\u6BB5");
			text_infield.setBounds(10, 150, 134, 26);
			text_infield.setColumns(10);
		}
		return text_infield;
	}

	public JButton getBtn_native2ascii() {
		if (btn_native2ascii == null) {
			btn_native2ascii = new JButton("Native2ASCII");
			btn_native2ascii.setMargin(new Insets(0, 0, 0, 0));
			btn_native2ascii.setFont(new Font("宋体", Font.PLAIN, 13));
			btn_native2ascii.setToolTipText("\u5C06\u4E0A\u65B9\u6587\u672C\u6267\u884Cnative2ascii");
			btn_native2ascii.setBounds(10, 86, 117, 26);
			btn_native2ascii.addMouseListener(getEvent());
		}
		return btn_native2ascii;
	}

	public JButton getBtn_ascii2native() {
		if (btn_ascii2native == null) {
			btn_ascii2native = new JButton("ASCII2Native");
			btn_ascii2native.setMargin(new Insets(0, 0, 0, 0));
			btn_ascii2native.setFont(new Font("宋体", Font.PLAIN, 13));
			btn_ascii2native.setToolTipText("\u5C06\u4E0A\u65B9\u6587\u672C\u6267\u884C\u9006\u5411native2ascii");
			btn_ascii2native.setBounds(139, 86, 117, 26);
			btn_ascii2native.addMouseListener(getEvent());
		}
		return btn_ascii2native;
	}

	public JButton getBtn_repfile() {
		if (btn_repfile == null) {
			btn_repfile = new JButton("\u6587\u4EF6\u66FF\u6362");
			btn_repfile.setMargin(new Insets(0, 0, 0, 0));
			btn_repfile.setFont(new Font("宋体", Font.PLAIN, 13));
			btn_repfile
					.setToolTipText("\u5C06\u4E0B\u65B9\u9009\u62E9\u7684\u76EE\u5F55\u4E2D\u7684\u6240\u6709\u6587\u4EF6\uFF08\u540E\u9762\u6807\u8BC6\u7684\u6587\u4EF6\u7C7B\u578B\uFF0C\u5982\uFF1Ahtml,HTML,htm,HTM......\uFF09\r\n\u6309\u89C4\u5219\u4E3A\uFF1A\u5C06\u4E0A\u65B9\u6587\u672C\u5185\u5BB9\uFF0C\u66FF\u6362\u4E3A\u4E0B\u65B9\u6587\u672C\u5185\u5BB9\uFF1B");
			btn_repfile.setBounds(139, 48, 117, 26);
			btn_repfile.addMouseListener(getEvent());
		}
		return btn_repfile;
	}
}